<?php


class WSB_Icon
{

	/**
	 * @var WSB_Icon
	 */
	private static $_instance;

	/**
	 * @var WSB_View_Helper_Icon
	 */
	private $_helper;

	/**
	 * @var Zend_Translate
	 */
	private $_translate;

	/**
	 * @return string
	 */
	public static function cleargif()
	{
		return self::_render('empty.gif', '');
	}

	/**
	 * @param string $url
	 * @param string $title
	 * @return string
	 */
	public static function help($url=null, $title=null)
	{
		return self::_render('famfam/help.png', 'icon:help', $url, $title);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function edit($url=null)
	{
		return self::_render('famfam/pencil.png', 'icon:edit', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function miniconEdit($url=null)
	{
		return self::_render('famfam/bullet_edit.png', 'icon:edit', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function view($url=null)
	{
		return self::_render('famfam/magnifier.png', 'icon:view', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function editContent($url=null)
	{
		return self::_render('famfam/layout_content.png', 'icon:editContent', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function undo($url=null)
	{
		return self::_render('famfam/arrow_rotate_anticlockwise.png', 'icon:undo', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function editXtContent($url=null)
	{
		return self::_render('famfam/application_view_columns.png', 'icon:editXtContent', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function page($url=null)
	{
		return self::_render('famfam/page.png', 'icon:page', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageFegroups($url = null)
	{
		return self::_render('famfam/page_fegroups.png', 'icon:pageFegroups', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageShortcut($url=null)
	{
		return self::_render('famfam/page_shortcut.png', 'icon:pageShortcut', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageShortcutNavhideFegroups($url = null)
	{
		return self::_render('famfam/page_shortcut_navhide_fegroups.png', 'icon:pageShortcutNavhideFegroups', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageShortcutNavhide($url = null)
	{
		return self::_render('famfam/page_shortcut_navhide.png', 'icon:pageShortcutNavhide', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageShortcutFegroups($url = null)
	{
		return self::_render('famfam/page_shortcut_fegroups.png', 'icon:pageShortcutFegroups', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageNavhideFegroups($url=null)
	{
		return self::_render('famfam/page_navhide_fegroups.png', 'icon:pageNavhideFegroups', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageNavhide($url=null)
	{
		return self::_render('famfam/page_navhide.png', 'icon:pageNavhide', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function pageHidden($url=null)
	{
		return self::_render('famfam/page_white.png', 'icon:pageHidden', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function configuration($url=null)
	{
		return self::_render('famfam/wrench.png', 'icon:configuration', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function miniconConfiguration($url=null)
	{
		return self::_render('famfam/bullet_wrench.png', 'icon:configuration', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function key($url=null)
	{
		return self::_render('famfam/key.png', 'icon:key', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function miniconKey($url=null)
	{
		return self::_render('famfam/bullet_key.png', 'icon:key', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function delete($url=null)
	{
		return self::_render('famfam/delete.png', 'icon:delete', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function hidden($url=null)
	{
		return self::_render('famfam/hidden.gif', 'icon:hidden', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function visible($url=null)
	{
		return self::_render('famfam/visible.gif', 'icon:visible', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function miniconDelete($url=null)
	{
		return self::_render('famfam/bullet_delete.png', 'icon:delete', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function file($url=null)
	{
		return self::_render('famfam/page_white.png', 'icon:file', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function folder($url=null)
	{
		return self::_render('famfam/folder.png', 'icon:folder', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function folderUp($url=null)
	{
		return self::_render('famfam/folder_up.png', 'icon:folderUp', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function cut($url=null)
	{
		return self::_render('famfam/cut.png', 'icon:cut', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function up($url=null)
	{
		return self::_render('famfam/arrow_up.png', 'icon:up', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function down($url=null)
	{
		return self::_render('famfam/arrow_down.png', 'icon:down', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function child($url=null)
	{
		return self::_render('famfam/arrow_right.png', 'icon:child', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function add($url=null)
	{
		return self::_render('famfam/add.png', 'icon:add', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function miniconAdd($url=null)
	{
		return self::_render('famfam/bullet_add.png', 'icon:add', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function miniconUp($url=null)
	{
		return self::_render('famfam/bullet_arrow_up.png', 'icon:up', $url);
	}

	/**
	 * @param string $url
	 * @return string
	 */
	public static function miniconDown($url=null)
	{
		return self::_render('famfam/bullet_arrow_down.png', 'icon:down', $url);
	}

	private function __construct()
	{
		$this->_helper = new WSB_View_Helper_Icon();
		$this->_translate = Zend_Registry::get('Zend_Translate');
		$locale = Zend_Registry::get('Zend_Locale');
		$translation = WSB_APP_PATH . 'i18n/icon.' . $locale.'.csv';
		$this->_translate->addTranslation($translation, $locale);
	}

	/**
	 * @return WSB_Icon
	 */
	private static function _instance()
	{
		if(is_null(self::$_instance)) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}

	/**
	 * @param string $file
	 * @param string $alt
	 * @param string $url
	 * @param string $title
	 * @return string
	 */
	private static function _render($file, $alt, $url=null, $title=null)
	{
		$instance = self::_instance();
		$alt = !empty($alt) ? $instance->_translate->translate($alt) : '';
		$attributes = array(
			'class' => 1,
			'title' => $title
		);
		if(empty($url)) {
			return $instance->_helper->icon($file, $alt, $attributes);
		} else {
			return WSB_Controller_Url::getHtmlLink($instance->_helper->icon($file, $alt, $attributes), $url);
		}
	}

}
